<?php
/*
+ ---------------------------------------------------------------------- +
| e107Shop - An e-commerce plugin for the e107 content management system |
|                                                                        |
| ByOrder Europe 2007-2008                                               |
| http://e107shop.com                                                    |
| patrick@byorder.nl                                                     |
|                                                                        |
| Released under the terms and conditions of the LGPL                    |
|                                                                        |
| $Revision: 1.0                                                         |
| $Date: 2008/08/20                                                      |
| $Author: Bieleke                                                       |
+ ---------------------------------------------------------------------- +
*/

//
// Admin Email
//
function e107shop_admin_purchase_message($order, $action)
{
    global $shop_settings;
    if($action=="s1")
    {
        $path = str_replace("gateways/handlers/", "", $shop_settings['path']);

        //
        // Successful purchase
        //
        $email_text = lan_outbound_admin_s00
        ."\r\n\r\n"
        .lan_outbound_admin_s02." ".$shop_settings["store_name"]
        ."\r\n\r\n"
        .lan_outbound_admin_s03."\r\n".$path."invoice.php?s=1&o=".$order
        ."\r\n\r\n"
        .lan_outbound_admin_s04."\r\n".lan_outbound_admin_s05
        ."\r\n\r\n"
        .lan_outbound_email_s07."\r\n".$shop_settings["store_name"];
    }
    if($action=="s2")
    {
        $path = str_replace("gateways/handlers/", "", $shop_settings['path']);

        //
        // Successful purchase
        //
        $email_text = lan_outbound_admin_s01
        ."\r\n\r\n"
        .lan_outbound_admin_s02." ".$shop_settings["store_name"]
        ."\r\n\r\n"
        .lan_outbound_admin_s03."\r\n".$path."invoice.php?s=1&o=".$order
        ."\r\n\r\n"
        .lan_outbound_admin_s04."\r\n".lan_outbound_admin_s05
        ."\r\n\r\n"
        .lan_outbound_email_s07."\r\n".$shop_settings["store_name"];
    }
    if($action=="p1")
    {
        $email_text = lan_outbound_admin_s00
        ."\r\n\r\n"
        .lan_outbound_admin_p01."\r\n".lan_outbound_admin_p02." ".$order
        ."\r\n\r\n"
        .lan_outbound_email_s07."\r\n".$shop_settings["store_name"];
    }
    if($action=="p2")
    {
        $email_text = lan_outbound_admin_s01
        ."\r\n\r\n"
        .lan_outbound_admin_p01."\r\n".lan_outbound_admin_p02." ".$order
        ."\r\n\r\n"
        .lan_outbound_email_s07."\r\n".$shop_settings["store_name"];
    }
    if($action=="c1")
    {
        $email_text = lan_outbound_admin_s00
        ."\r\n\r\n"
        .lan_outbound_admin_c01." ".$order." ".lan_outbound_admin_c02."\r\n"
        .lan_outbound_admin_c03
        ."\r\n\r\n"
        .lan_outbound_email_s07."\r\n".$shop_settings["store_name"];
    }
    if($action=="c2")
    {
        $email_text = lan_outbound_admin_s01
        ."\r\n\r\n"
        .lan_outbound_admin_c01." ".$order." ".lan_outbound_admin_c02."\r\n"
        .lan_outbound_admin_c03
        ."\r\n\r\n"
        .lan_outbound_email_s07."\r\n".$shop_settings["store_name"];
    }
    if($action=="pe1")
    {
        $email_text = lan_outbound_admin_s00
        ."\r\n\r\n"
        .lan_outbound_admin_pe01." ".$order
        ."\r\n\r\n"
        .lan_outbound_email_s07."\r\n".$shop_settings["store_name"];
    }
    if($action=="pe2")
    {
        $email_text = lan_outbound_admin_s01
        ."\r\n\r\n"
        .lan_outbound_admin_pe01." ".$order
        ."\r\n\r\n"
        .lan_outbound_email_s07."\r\n".$shop_settings["store_name"];
    }
    if($action=="nt1")
    {
        if ($pos = strpos($shop_settings['path'], "gateways/handlers/")) {
            $path = str_replace("gateways/handlers/", "", $shop_settings['path']);
        } elseif ($pos = strpos($shop_settings['path'], "admin/")) {
            $path = str_replace("admin/", "", $shop_settings['path']);
        }

        //
        // Successful purchase
        //
        $email_text = lan_outbound_admin_s00
        ."\r\n\r\n"
        .lan_outbound_admin_s06." ".$shop_settings["store_name"]
        ."\r\n\r\n"
        .lan_outbound_admin_s07."\r\n".$path."invoice.php?s=1&o=".$order
        ."\r\n\r\n"
        .lan_outbound_admin_s04."\r\n\r\n"
        .lan_outbound_email_s07."\r\n".$shop_settings["store_name"];
    }
    if($action=="nt2")
    {
        if ($pos = strpos($shop_settings['path'], "gateways/handlers/")) {
            $path = str_replace("gateways/handlers/", "", $shop_settings['path']);
        } elseif ($pos = strpos($shop_settings['path'], "admin/")) {
            $path = str_replace("admin/", "", $shop_settings['path']);
        }

        //
        // Successful purchase
        //
        $email_text = lan_outbound_admin_s01
        ."\r\n\r\n"
        .lan_outbound_admin_s06." ".$shop_settings["store_name"]
        ."\r\n\r\n"
        .lan_outbound_admin_s07."\r\n".$path."invoice.php?s=1&o=".$order
        ."\r\n\r\n"
        .lan_outbound_admin_s04."\r\n\r\n"
        .lan_outbound_email_s07."\r\n".$shop_settings["store_name"];
    }
    if($action=="pay1") {
        $path = str_replace("gateways/handlers/", "", $shop_settings['path']);
        // Successful purchase
        $email_text = lan_outbound_admin_s00
        ."\r\n\r\n"
        .lan_outbound_admin_pm1." ".$shop_settings["store_name"]." ".lan_outbound_admin_pm2."\r\n\r\n"
        .lan_outbound_admin_s03."\r\n".$path."invoice.php?s=1&o=".$order
        ."\r\n\r\n"
        .lan_outbound_admin_s04."\r\n\r\n"
        .lan_outbound_email_s07."\r\n".$shop_settings["store_name"];
    }
    if($action=="pay2") {
        $path = str_replace("gateways/handlers/", "", $shop_settings['path']);
        // Successful purchase
        $email_text = lan_outbound_admin_s01
        ."\r\n\r\n"
        .lan_outbound_admin_pm1." ".$shop_settings["store_name"]." ".lan_outbound_admin_pm2."\r\n\r\n"
        .lan_outbound_admin_s03."\r\n".$path."invoice.php?s=1&o=".$order
        ."\r\n\r\n"
        .lan_outbound_admin_s04."\r\n\r\n"
        .lan_outbound_email_s07."\r\n".$shop_settings["store_name"];
    }
    if($action=="t1") {
        $email_text = lan_outbound_admin_t01." ".$shop_settings["store_name"];
    }
    if($action=="t2") {
        $email_text = lan_outbound_admin_t02;
    }
    if($action=="t3") {
        $email_text = lan_outbound_admin_t03;
    }
    if($action=="t4") {
        $email_text = lan_outbound_admin_t04;
    }
    if($action=="t5") {
        $email_text = lan_outbound_admin_t05;
    }
    if($action=="t6") {
        $email_text = lan_outbound_admin_t06;
    }
    if($action=="t7") {
        $email_text = lan_outbound_admin_t07;
    }
    if($action=="t8") {
        $email_text = lan_outbound_admin_t08;
    }
    if($action=="pnt1") {
        $email_text = lan_outbound_admin_pnt1;
    }
    if($action=="pnt2") {
        $email_text = lan_outbound_admin_pnt2;
    }
    if($action=="paid") {
        $email_text = lan_outbound_admin_paid." ".$shop_settings["store_name"];
    }
    if($action=="paid2") {
        $email_text = lan_outbound_admin_paid2;
    }


    return $email_text;

}


//
// Email to the customer on successfull purchase
//

function e107shop_customer_purchase_message($order, $action)
{
    global $shop_settings;
    $path = str_replace("admin/", "", $shop_settings['path']);
    if($action=="s")
    {
        //
        // Successful order
        //
        $email_text = lan_outbound_email_s01
        ."\r\n\r\n"
        .lan_outbound_email_s02." ".$shop_settings["store_name"]." ".lan_outbound_email_s03
        ."\r\n\r\n"
        .lan_outbound_email_s04."\r\n".$path."order.php?s=1&o=".$order
        ."\r\n\r\n"
        .lan_outbound_email_s05
        ."\r\n\r\n"
        .lan_outbound_email_s06
        ."\r\n\r\n"
        .lan_outbound_email_s07."\r\n".$shop_settings["store_name"];
    }
    if($action=="p")
    {
        //
        // Process error
        //
        $email_text = lan_outbound_email_s01
        ."\r\n\r\n"
        .lan_outbound_email_p01
        ."\r\n\r\n"
        .lan_outbound_email_p02."\r\n"
        .lan_outbound_admin_p02." ".$order
        ."\r\n\r\n"
        .lan_outbound_email_s07."\r\n".$shop_settings["store_name"];
    }
    if($action=="c")
    {
        //
        // Not found in cart
        //
        $email_text = lan_outbound_email_s01
        ."\r\n\r\n"
        .lan_outbound_email_c01." ".$order." ". lan_outbound_email_c02
        ."\r\n\r\n"
        .lan_outbound_email_c03
        ."\r\n\r\n"
        .lan_outbound_email_s07."\r\n".$shop_settings["store_name"];
    }
    if($action=="pe")
    {
        $email_text = lan_outbound_email_s01
        ."\r\n\r\n"
        .lan_outbound_email_p01
        ."\r\n\r\n"
        .lan_outbound_email_pe01
        ."\r\n\r\n"
        .lan_outbound_email_s07."\r\n".$shop_settings["store_name"];
    }
    if($action=="nt")
    {
        //
        // Non tangible product (downloadable)
        //
        $email_text = lan_outbound_email_s01
        ."\r\n\r\n"
        .lan_outbound_email_nt01."\r\n".$path."download.php?s=1&o=".$order
        ."\r\n\r\n"
        .lan_outbound_email_nt02
        ."\r\n\r\n"
        .lan_outbound_email_s07."\r\n".$shop_settings["store_name"];
    }
    if($action=="pay")
    {
        //
        // Successful order
        //
        $email_text = lan_outbound_email_s01
        ."\r\n\r\n"
        .lan_outbound_email_s02." ".$shop_settings["store_name"]." ".lan_outbound_email_s08
        ."\r\n\r\n"
        .lan_outbound_email_s09."\r\n".$path."invoice.php?s=1&o=".$order
        ."\r\n\r\n"
        .lan_outbound_email_s07."\r\n".$shop_settings["store_name"];
    }
    return $email_text;
}
